package com.bootdo.mall.dao;

import com.bootdo.mall.domain.MallGood;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 商品
 * @author haojiangbo
 * @email 2100272728@qq.com
 * @date 2019-10-24 19:42:31
 */
@Mapper
public interface MallGoodDao {

	MallGood get(Long id);

	MallGood getMin(Long id);
	
	List<MallGood> list(Map<String,Object> map);

	List<MallGood> getGoodListByCategoryId(Map<String,Object> map);

	Integer getGoodCountByCategoryId(Map<String,Object> map);
	List<MallGood> getGoodListByIndex(Map<String,Object> map);
	Integer getGoodCountByIndex(Map<String,Object> map);
	@Update("update me_mall_good set stock = stock+#{stock} where id = #{id}")
 	Integer updateStockAdd(@Param("stock") Integer stock, @Param("id") Long id);

	@Update("update me_mall_good set stock = stock-#{stock} where id = #{id} and stock >= #{stock}")
	Integer updateStockDel(@Param("stock") Integer stock, @Param("id") Long id);


	
	int count(Map<String,Object> map);
	
	int save(MallGood mallGood);
	
	int update(MallGood mallGood);
	
	int remove(Long id);
	
	int batchRemove(Long[] ids);
}
